$(document).ready(function(){
    var _prizelist=[];
    var ltt = new ltt_load();
    var _imgs;
    var _canvas;
    var _stage;
    var _ftps=60;
    var _userlist;
    var _wins=[337.5,292.5,247.5,202.5,157.5,112.5,67.5,22.5];
    var _playing=false;
    var _mcmin;
    var _canplayTimes;
    var _canplayTimesall;
    var _yzmtime=null;          //验证码变量
    var _pointexchnage;     //是否支持积分兑换
    var _mode;              //2.九宫格大转盘 其它 园形大转盘
    var _nowPot=-1;         //方形大转盘 初始化位置
    var _totalUse;          //玩过的总次数（不算积分兑换);
    var _points;            //多少积分兑换一次机会
    var _touxsrc;
    var _activityState;
    var _other;
    var _nickname;      //微信昵称

    var _post=new AjaxPost();
    var d=copydata(window.senddatas);
    $('.loading2').show();
    _post.sendScore(window.staticurl+'index',d,function(d){
        if(d.code.errcode=='0'){
            $('title').html(d.data.activityName);
            _prizelist= d.data.prizeList;
            _pointexchnage= d.data.pointExchange;
            _mode= d.data.diskStyle;
            _touxsrc= d.data.photo;
            _activityState= d.data.activityState;
            _other= d.data.other;
            _nickname= d.data.nick;
            //_mode=1;
            if(_mode==2){
                _imgs=Game2.properties.manifest;
                $('.index .cons .prizes').addClass('fang');
                addxgmbtp( $('.index .cons .prizes:eq(0) .logo_win'),'z');
                addxgmbtp( $('.index .cons .prizes:eq(1) .logo_win'),'z');
            }else{
                _imgs=Game.properties.manifest;
                addxgmbtp( $('.index .cons .prizes:eq(0) .logo_win'),'');
                addxgmbtp( $('.index .cons .prizes:eq(1) .logo_win'),'');
            }
            for(var i=0;i<_prizelist.length;i++){
                var s={};
                s.id='img_'+_prizelist[i].prizePostition;
                if(_prizelist[i].icon=='1'||_prizelist[i].icon=='2'||_prizelist[i].icon=='3'
                    ||_prizelist[i].icon=='4'||_prizelist[i].icon=='5'||_prizelist[i].icon=='6'
                    ||_prizelist[i].icon=='7'||_prizelist[i].icon=='8'||_prizelist[i].icon=='9'){
                    if(_prizelist[i].prizePostition%2==1&&_mode!=2){
                        s.src=window.staticPath+'/images/icon/'+_prizelist[i].icon+'-'+1+'.png';
                    }else{
                        s.src=window.staticPath+'/images/icon/'+_prizelist[i].icon+'-'+2+'.png';
                    }
                }else{
                    s.src=_prizelist[i].icon;
                }
                _imgs.push(s);
            }
            if(_mode==2){
                addImage(images_game2);
                ltt.ltts([_imgs],[images_game2],function(){},function(){
                    $('.loading2').hide();
                    $('.daddy').show();
                    pz();
                    initPan2();
                });
            }else{
                addImage(images_game);
                ltt.ltts([_imgs],[images_game],function(){},function(){
                    $('.loading2').hide();
                    $('.daddy').show();
                    pz();
                    initPan();
                });
            }
            _userlist= d.data.userinfo;

            $('.index .cons .prizes .says').html(d.data.explain)
            $('.index .cons .prizes .time').html(d.data.startTime+' ~ '+d.data.endTime);
            if(_activityState==0){
                $('.index .cons .times').html('活动暂未开始哦~');
            }else if(_activityState==1){
                $('.index .cons .times .num').html(d.data.remainCount);
            }else{
                $('.index .cons .times').html('活动已经结束啦~');
            }
            _canplayTimes=d.data.remainCount;
            _canplayTimesall=d.data.remainTotalCount;
            _totalUse= d.data.totalUse;
            _points= d.data.points;
            // getphb();

            var music=d.data.musicName;
            if(music!=null){
                var audio=new Audio();
                audio.src=music;
                audio.loop=true;
                audio.play();

                $(window).on('touchstart',onMusicHandle);

                function onMusicHandle(){
                    $(window).off('touchstart',onMusicHandle);
                    audio.play();
                }
            }

            if(d.data.backgroundImg!=null&&d.data.backgroundImg!=undefined&&d.data.backgroundImg!=''){
                $('.index .bg').attr('src',d.data.backgroundImg);
            }else{
                $('.index .bg').attr('src',window.staticPath+'/images/bg.jpg');
            }
            addshareHandle(window.sharelink, d.data.shareLogo, d.data.shareTitle, d.data.shareDescription);

         }else{
            //location.href=window.errors;
        }
    });

    /***修改模板图片***/
    function addxgmbtp(mc,str){
        var cc=mc.attr('src2')+str+'.png';
        mc.attr('src',cc);
    }

    /****图片地址加前缀***/
    function addImage(arrs){
        for(var i=0;i<arrs.length;i++){
            arrs[i].src=window.staticPath+arrs[i].src;
        }
    }

    /***获取排行榜***/
    function getphb(){
        var post=new AjaxPost();
        var dataphb=null;
        var ds=copydata(window.senddatas);
        ds.limit=50;
        ds.start=0;
        var _time;
        var _ul1or=-1;
        $('.index .cons .getprize ul').html('');
        updateItems();

        function postit(){
            if(dataphb==null||dataphb.length==0){
                if(_playing){
                    _time=setTimeout(function(){
                        updateItems();
                    },2000);
                    return;
                }
                post.sendScore(window.staticurl+'winnerList',ds,function(d){
                    if(d.code.errcode=='0'){
                        dataphb= d.data.items;
                        if(dataphb==null||dataphb.length==0){
                            $('.index .cons .getprize').hide();
                        }else{
                            $('.index .cons .getprize').show();
                        }
                        _time=setTimeout(function(){
                            updateItems();
                        },2000);
                    }
                })
            }
        }

        function updateItems(){
            if(dataphb==null||dataphb.length==0){
                postit();
            }else{
                if(_ul1or<=0){
                    $('.index .cons .getprize .ul1').html('');
                }else{
                    $('.index .cons .getprize .ul2').html('');
                }
                for(var i=0;i<3;i++){
                    if(dataphb.length==0){
                        dataphb=null;
                        break;
                    }else{
                        var str='<li><p class="names">恭喜 '+dataphb[0].userName+' </p> <p class="names right">获得 '+dataphb[0].prizeName+'</p></li>';
                        if(_ul1or<=0){
                            $('.index .cons .getprize .ul1').append(str);
                        }else{
                            $('.index .cons .getprize .ul2').append(str);
                        }
                        dataphb.splice(0,1);
                    }
                }
                if(_ul1or==0){
                    var num=$('.index .cons .getprize .ul2 li').length;
                    if(num==0) num=3;
                    $('.index .cons .getprize .ul2').css({'left':'17rem','lineHeight':4.8/num+'rem'});
                    $('.index .cons .prizes .ul1').animate({
                        'left':'-19rem'
                    },300);
                    $('.index .cons .getprize .ul2').animate({
                        'left':'1.5rem'
                    },300);
                    _ul1or=1;
                }else if(_ul1or==1){
                    var num=$('.index .cons .getprize .ul1 li').length;
                    if(num==0) num=3;
                    $('.index .cons .getprize .ul1').css({'left':'17rem','lineHeight':4.8/num+'rem'});
                    $('.index .cons .getprize .ul2').animate({
                        'left':'-19rem'
                    },300);
                    $('.index .cons .getprize .ul1').animate({
                        'left':'1.5rem'
                    },300);
                    _ul1or=0;
                }else{
                    _ul1or=1;
                }
                _time=setTimeout(function(){
                    updateItems();
                },2000);
            }
        }
    }

    /********2种转盘共有的******/


    /***抽奖****/
    function chouPrize(){
        if(_pointexchnage==1&&_canplayTimes<=0){
            showExchange();
            return;
        }else if(_canplayTimes<=0){
            alertss('今天抽奖机会已经用完啦~<br/>明天再来吧');
            return;
        }

        _playing=true;
        $('.loading2').show();
        $('.loading2 img').hide();
        var ss=setTimeout(function(){
            $('.loading2 img').show();
        },1000);
        var d=copydata(window.senddatas);
        _post.sendScore(window.staticurl+'startBigWheel',d,function(d){
            clearTimeout(ss);
            if(d.code.errcode==0){
                _canplayTimes--;
                $('.index .cons .times .num').html(_canplayTimes);
                var cc=d.data.settingId;
                for(var i=0;i<_prizelist.length;i++){
                    if(_prizelist[i].bwsId==cc){
                        if(_mode==2){
                            playPan2(parseInt(_prizelist[i].prizePostition)-1,_prizelist[i], d.data.type);
                        }else{
                            playPan(_wins[parseInt(_prizelist[i].prizePostition)-1],_prizelist[i], d.data.type);
                        }
                        break;
                    }
                }
            }else{
                showError(d,1);
                _playing=false;
            }
        });
    }

    /***圆形转盘**/
    /*************************************************************************************************************************/
    /***添加大转盘***/
    function initPan(){
        var mc=new Game.main();
        _mcmin=mc.pan;
        var btnprize=mc.btn_prize;
        var btn_myprize=mc.btn_myprize;

        _stage.addChild(mc);
        paixu(_prizelist);
        for(var i=0;i<_prizelist.length;i++){
            _mcmin['t_'+i].text=_prizelist[i].prizeName;
            var cc=new createjs.Bitmap(images_game['img_'+_prizelist[i].prizePostition]);
            cc.x=-cc.getBounds().width/2;
            cc.y=-cc.getBounds().height/2;
            _mcmin['i_'+i].addChild(cc);
        }

        btnprize.addEventListener('click',function(){
            if(_playing) return;
            if(_activityState==0){
                alertss('活动未开始！');
                return;
            }else if(_activityState==2){
                alertss('活动已结束！');
                return;
            }
            if(_userlist!=null&&_userlist.length!=0){
                showUpUser(0,function(){
                    chouPrize();
                });
            }else{
                chouPrize();
            }
        });

        btn_myprize.addEventListener('click',function(){
            location.href='/prize/'+window.senddatas.aid+'/'+window.senddatas.activityId;
        });
    }

    /***转盘***/
    function playPan(c,d,t){
        var _speed=1;
        var _maxspeed=25;
        var _jiasus=2;
        var _jiasu=0;
        var _jiansu=0;
        var _jiansus=1;
        var _jszt=2;
        var s=0;
        var num=0;
        var nums=10;
        for(var i=3;i<=_maxspeed;i+=_jszt){
            s=s+i*(_maxspeed-i+1);
        }
        s+=c;
        var start=s%360;
        createjs.Ticker.addEventListener("tick", onflyingHandle);

        function onflyingHandle(){
            _jiasu++;
            if(_jiasu%_jiasus==0&&num<nums) {
                _jiasu=0;
                if(_speed<_maxspeed) _speed+=3;
            }
            _mcmin.rotation+=_speed;
            if(_mcmin.rotation>360){
                _mcmin.rotation-=360;
                if(num<nums){
                    num++;
                }
            }
            if(_mcmin.rotation<=30) var ss=_mcmin.rotation+360;
            else var ss=_mcmin.rotation;
            if(nums==num&&(ss-start)<=_maxspeed){
                num++;
            }
            if(num>nums){
                if(_jiansus==_jiansu){
                    _speed-=_jszt;
                    if(_speed<=3) _speed=3;
                    _jiansus++;
                    _jiansu=0;
                }
                if(_speed==0||(_speed<5&&Math.abs(_mcmin.rotation-c)<8)){
                    _mcmin.rotation=c;
                    createjs.Ticker.removeEventListener("tick", onflyingHandle);
                    setTimeout(function(){
                        showOverPrize(d,t);
                        _playing=false;
                    },500);
                }
                _jiansu++;
            }

        }
    }
    /*************************************************************************************************************************/

    /******方形转盘*****/
    /*************************************************************************************************************************/
    /***添加大转盘***/
    function initPan2(){
        var mc=new Game2.main();
        _mcmin=mc;
        var btnprize=mc.btn_prize;
        var btn_myprize=mc.btn_myprize;
        _mcmin.bg.gotoAndStop(0);

        _stage.addChild(mc);
        paixu(_prizelist);
        for(var i=0;i<_prizelist.length;i++){
            _mcmin['t_'+i].tt.text=_prizelist[i].prizeName;
            var cc=new createjs.Bitmap(images_game2['img_'+_prizelist[i].prizePostition]);
            cc.x=-cc.getBounds().width/2+82;
            cc.y=-cc.getBounds().height/2+40;
            _mcmin['t_'+i].addChild(cc);
        }

        btnprize.addEventListener('click',function(){
            if(_playing) return;
            if(_activityState==0){
                alertss('活动未开始！');
                return;
            }else if(_activityState==2){
                alertss('活动已结束！');
                return;
            }
            if(_userlist!=null&&_userlist.length!=0){
                showUpUser(0,function(){
                    chouPrize();
                });
            }else{
                chouPrize();
            }
        });

        btn_myprize.addEventListener('click',function(){
            location.href='/prize/'+window.senddatas.aid+'/'+window.senddatas.activityId;
        });
    }

    /***转盘***/
    function playPan2(c,d,t){
        _mcmin.btn_prize.gotoAndStop(1);
        var _speed=8;
        var _maxspeed=3;
        var _quan=5;
        var _ss=7;
        var _downstart=c;
        for(var i=_maxspeed;i<25;i+=2){
            _downstart-=i;
            if(_downstart<0) _downstart+=8;
        }
        createjs.Ticker.addEventListener("tick", onflyingHandle);

        function onflyingHandle(){
            _mcmin.bg.play();
            _ss++;
            if(_ss==_speed){
                if(_quan==-1){
                    _speed+=2;
                }else if(_quan==0&&_downstart==_nowPot){
                    _quan=-1;
                }
                if(_nowPot!=-1){
                    _mcmin['t_'+_nowPot].gotoAndStop(0);
                }
                _nowPot++;
                if(_nowPot>7){
                    _nowPot%=8;
                    if(_speed==_maxspeed){
                        _quan--;
                    }
                }
                _mcmin['t_'+_nowPot].gotoAndStop(1);
                if(_speed>_maxspeed&&_quan>0){
                    _speed-=2;
                }else if(_speed<=_maxspeed){
                    _speed=_maxspeed;
                }
                _ss=0;
                if(_speed>24&&c==_nowPot){
                    _mcmin.bg.gotoAndStop(0);
                    createjs.Ticker.removeEventListener("tick", onflyingHandle);
                    setTimeout(function(){
                        showOverPrize(d,t);
                        _playing=false;
                        _mcmin.btn_prize.gotoAndStop(0);
                    },800);
                }
            }

        }
    }
    /*************************************************************************************************************************/


    /***兑换积分****/
    function showExchange(){
        showTCSp($('.exchange'),function(){
            $('.exchange .btn_sure').off('click');
        });

        if(_canplayTimes<=0&&_canplayTimesall<=0){
            if(_totalUse<=0){
                $('.exchange .wins').html('确定使用'+_points+'积分玩一次吗？');
            }else{
                $('.exchange .wins').html('抽奖机会已经用完啦~<br/>确定使用'+_points+'积分再玩一次吗？');
            }
        }else if(_canplayTimes<=0){
            $('.exchange .wins').html('今天的抽奖机会已经用完啦~<br/>确定使用'+_points+'积分再玩一次吗？');
        }


        $('.exchange .btn_sure').on('click',function(){
            var d=copydata(window.senddatas);
            $('.loading2').show();
            _post.sendScore(window.staticurl+'exchangePoints',d,function(d){
                $('.exchange .btn_close').click();
                if(d.code.errcode=='0'){
                    alertss('兑换成功',function(){
                        _canplayTimes++;
                        chouPrize();
                    });
                }else{
                    showError(d,2)
                }
            });
        });
    }


    /****抽奖错误报错***/
    function showError(d,type){
        if(d.code.errcode=='861010042001712'){
            alertss('活动未开始！');
        }else if(d.code.errcode=='861010042001713'){
            alertss('活动已结束！');
        }else if(d.code.errcode=='861010042001729'&&type==1){
            alertss('很抱歉，您暂时未满足参与活动的条件请联系商家！');
        }else if(d.code.errcode=='861010042005728'&&type==2){
            alertss('积分不足');
        }else if((d.code.errcode=='861010042001730'&&type==1)||(d.code.errcode=='861010042005730'&&type==2)){
            alertss('您还不是会员哦~');
            $('.alertss .cons .btn_close').off('click');
            $('.alertss .cons .btn_close').html('立即注册');
            $('.alertss .cons .btn_close').on('click',function(){
                location.href= d.exp.url;
            });
        }else if((d.code.errcode=='861010042001731'&&type==1)||(d.code.errcode=='861010042005731'&&type==2)){
            alertss('您还不是会员哦~');
            $('.alertss .cons .btn_close').off('click');
            $('.alertss .cons .btn_close').html('立即注册');
            $('.alertss .cons .btn_close').on('click',function(){
                location.href= d.exp.url;
            });
        }else{
            alertss(d.code.errmsg);
        }
    }


    /***显示结果***/
    function showOverPrize(d,t){
        if(t==8){
            alertss('太可惜了，<br/>差一点就中奖了~');
        }else{
            showTCSp($('.winner'));
            $('.winner .btn_close').off('click');
            $('.winner .says').html(d.prizeName);
            $('.winner .prizeimg img').attr('src', d.prizePic);
        }

    }

    /***提交用户信息***/
    function showUpUser(type,fun){
        $('.mydata .con ul').html('');
        $('.mydata .savedata').val('');
        for(var i=0;i<_userlist.length;i++){
            pushinput(_userlist[i]);
        }
        $('.mydata .con .tou img').attr('src',_touxsrc);
        $('.mydata .con .nickname').html(_nickname);
        showTCSp($('.mydata'),function(){
            $('.mydata .btn_sure').off('click',onSendHandle);
        });

        function pushinput(num){
            if(num==0){
                var str=' <li><input type="text" class="savedata" name="yzm" placeholder="请填写验证码" /><a href="javascript:;" class="getBtn">获取验证码</a></li>';
                str=$(str);
                var cansendyzm=false;
                str.find('.getBtn').on('click',function(){
                    if(cansendyzm) return;
                    cansendyzm=true;
                    var post=new AjaxPost();
                    var d=copydata(window.senddatas);
                    d.phone=$('.mydata .con ul li .phone').val();
                    if(!textTel(d.phone)){
                        hideTCSp1($('.mydata'),function(){
                            alertss('手机格式不正确！',function(){
                                showTCSp($('.mydata'));
                            });
                        });
                        return;
                    }
                    $('.loading2').show();
                    post.sendScore(window.staticurl+'sendcode',d,function(d){
                        if(d.code.errcode=='0'){
                            var timemax=60;
                            str.find('.getBtn').html(timemax+'s');
                            _yzmtime=setInterval(function(){
                                timemax--;
                                if(timemax>0){
                                    str.find('.getBtn').html(timemax+'s');
                                }else{
                                    str.find('.getBtn').html('获取验证码');
                                    cansendyzm=false;
                                    clearInterval(_yzmtime);
                                }
                            },1000);
                        }else{
                            cansendyzm=false;
                        }
                    });
                });
            }else if(num==1){
                var str='<li><input type="text" class="savedata"  name="" data-rule-required="true"  placeholder="微信昵称" /></li>'
            }else if(num==2){
                var str='<li><input type="text" class="savedata"  name="name" data-rule-required="true"  placeholder="真实姓名" /></li>'
            }else if(num==3){
                var str='<li><input type="text" class="savedata phone"  name="phone" data-rule-Mobile="true"  placeholder="手机号" /></li>'
            }else if(num==4){
                var str='<li><input type="text" class="savedata"  name="mail" data-rule-Mail="true"  placeholder="邮箱" /></li>'
            }else if(num==5){
                var str='<li><input type="text" class="savedata"  name="wechat" data-rule-required="true"  placeholder="微信号" /></li>'
            }else if(num==6){
                var str='<li><input type="text" class="savedata"  name="qq" data-rule-num="true"  placeholder="QQ号" /></li>'
            }else if(num==7){
                var str='<li><input type="text" class="savedata"  name="address" data-rule-required="true"  placeholder="邮寄地址" /></li>'
            }else if(num==8){
                var str='<li><input type="text" class="savedata"  name="otherOption" data-rule-required="true"  placeholder="'+_other+'" /></li>'
            }
            $('.mydata .con ul').append(str);
        }
        $('.mydata .btn_sure').on('click',onSendHandle);

        function onSendHandle(){
            //alert('提交信息');

            var errorArr=selectedInput('.savedata');
            for(var i=0;i<errorArr.length;i++){
                if(errorArr[i].error){
                    $('.mydata .btn_close').click();
                    if(errorArr[i].required){
                        hideTCSp1($('.mydata'),function(){
                            alertss('信息未填写完整！',onBackHandle);
                        });
                        return;
                    }else if(errorArr[i].mobile){
                        hideTCSp1($('.mydata'),function() {
                            alertss('手机格式有误！', onBackHandle);
                        });
                        return;
                    }else if(errorArr[i].mail){
                        hideTCSp1($('.mydata'),function(){
                            alertss('邮箱格式有误！',onBackHandle);
                        });
                        return;
                    }else if(errorArr[i].number){
                        hideTCSp1($('.mydata'),function(){
                            alertss('QQ号为纯数字！',onBackHandle);
                        });
                        return;
                    }
                }
            }

            var d=copydata(window.senddatas);
            d.type=type;
            getInputData('.savedata',d);
            $('.loading2').show();
            _post.sendScore(window.staticurl+'updateuserinfo',d,function(d){
                if(d.code.errcode=='0'){
                    _userlist=null;
                    if(_yzmtime!=null) clearInterval(_yzmtime);
                    if(fun!=null) fun();
                }else{
                    alertss(d.code.errmsg,onBackHandle);
                }
                $('.mydata .btn_sure').off('click',onSendHandle);
                $('.mydata .btn_close').click();
            });
        }

        function onBackHandle(){
            //$('.mydata .savedata').val('');
            showTCSp($('.mydata'),function(){
                $('.mydata .btn_sure').off('click',onSendHandle);
            });
            $('.mydata .btn_sure').on('click',onSendHandle);
        }
    }



    /**
     * 排序
     */
    function paixu(list){
        for(var i=0;i<list.length;i++){
            for(var j=i;j<list.length;j++){
                if(list[j].prizePostition==i){
                    if(j==i) continue;
                    else{
                        var c=list[j];
                        list[j]=list[i];
                        list[i]=c;
                        continue;
                    }
                }
            }
        }
    }

    function hideTCSp1(mc,fun){
        mc.hide();
        fun();
    }



    /*******************����********************/
    function pz() {
        _canvas = getid('dzp');
        _stage = new createjs.Stage(_canvas);
        //createjs.Touch.enable(_stage);
        createjs.Ticker.setFPS(_ftps);
        createjs.Ticker.addEventListener("tick", _stage);
    }
    /*****************���ܺ���************************/
    function getid(str) {
        return document.getElementById(str);
    }

});


/****************alert******************/
function alertss(str,fun){
    var mc;
    if($('.alertss').length==0){
        var dd='<div class="tan alertss"><div class="cons"><img src="/assets/shopmobile/bigwheel/images/btn_alert_bg.png" class="bg">'+
            '<div class="con"><p class="says">sss</p><a href="javascript:;" class="btn_close">知道了</a></div></div></div>';
        mc=$(dd);
        $('body').append(mc);
    }else{
        mc=$('.alertss');
    }
    mc.find('.says').html(str);
    showTCSp(mc,function(){
        if(fun!=undefined) fun();
    });

}

function showTCSp(mc,fun) {
    mc.show();
    var c = mc.find('.cons');
    var h = c.height();
    var hh = $(window).height();
    var ccsd = (hh - h) / 2;
    if (ccsd < 0) ccsd = 0;
    c.css({'top': ccsd});
    if (h > hh) hh = h;
    $('.daddy').css({'height': hh, 'overflow': 'hidden'});

    mc.find('.btn_close').on('click', function () {
        mc.find('.btn_close').off('click');
        $('.daddy').css({'height':'auto','overflow':'inherit'});
        mc.hide();
        if (fun != undefined) fun()
    });
}

/******************************************************************************************************************************/
function ltt_load() {
    this.ltts = function (arrs, images, progress, complete) {
        var loaders = [];
        for (var i = 0; i < arrs.length; i++) {
            if (images != null) {
                for (var j = 0; j < arrs[i].length; j++) {
                    arrs[i][j].image = images[i];
                }
            }
            loaders = loaders.concat(arrs[i]);
        }
        var queue = new createjs.LoadQueue(false);
        queue.loadManifest(loaders);
        queue.on("fileload", handleFileLoad);
        queue.on("complete", handleComplete);
        queue.on("progress", handleProgress);
        function handleFileLoad(evt) {
            if (evt.item.type == "image" && images != null) {
                evt.item.image[evt.item.id] = evt.result;
            }
        }

        function handleComplete() {
            if (complete != null && complete != undefined && complete != '') {
                complete();
            }
        }

        function handleProgress(a) {
            if (progress != null && progress != undefined && progress != '') {
                progress(a.progress);
            }
        }
    }
}




